//
//  FriendIDCheckViewController.m
//  MyYiJianKangApp
//
//  Created by 张国文 on 16/4/5.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "FriendIDCheckViewController.h"
#import "FriendIDNextViewController.h"


@interface FriendIDCheckViewController ()<UITextViewDelegate>

@property (nonatomic, strong) UIImageView *friendImageV; // 好友头像
@property (nonatomic, strong) UILabel *friendName; // 好友姓名
@property (nonatomic, strong) UITextView *IDCheckTF; // 身份验证

@end

@implementation FriendIDCheckViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.03];
    // navi的修改
    [self changeNavigation];
   
}

- (void)viewWillAppear:(BOOL)animated
{
    // 视图布局
    [self addMySubview];
}

// navi的修改
- (void)changeNavigation
{
    [self.navigationController.navigationBar setTranslucent:NO];
    self.navigationItem.title = @"身份验证";
    UIImageView *leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    leftImageView.image = [UIImage imageNamed:@"houtui"];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftImageView];
    UITapGestureRecognizer *leftTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lastPage:)];
    [leftImageView addGestureRecognizer:leftTapGes];
    
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"下一步" style:UIBarButtonItemStylePlain target:self action:@selector(nextPage:)];
    rightItem.tintColor = [UIColor whiteColor];
    self.navigationItem.rightBarButtonItem = rightItem;
    
}

#pragma mark - 返回上一页面
- (void)lastPage:(UITapGestureRecognizer *)tapGes
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - 下一步
- (void)nextPage:(UIBarButtonItem *)rightItem
{
    FriendIDNextViewController *friendIDNextVC = [[FriendIDNextViewController alloc] init];
    [self.navigationController pushViewController:friendIDNextVC animated:YES];
}

#pragma mark - 视图布局
- (void)addMySubview
{
//    // 灰色背景
    UILabel *grayBackView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    grayBackView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.03];
    [self.view addSubview:grayBackView];
    self.friendImageV = [[UIImageView alloc] initWithFrame:CGRectMake(10 * kAdjustParamater, 20 * kAdjustParamater, 50 * kAdjustParamater, 50 * kAdjustParamater)];
    self.friendImageV.backgroundColor = [[UIColor yellowColor] colorWithAlphaComponent:0.5];
    self.friendImageV.layer.cornerRadius = 25 * kAdjustParamater;
    [grayBackView addSubview:_friendImageV];
    
    self.friendName = [[UILabel alloc] initWithFrame:CGRectMake(self.friendImageV.right + 10 * kAdjustParamater, self.friendImageV.top + 15 * kAdjustParamater, 150 * kAdjustParamater, 20 * kAdjustParamater)];
 //   self.friendName.backgroundColor = [UIColor redColor];
    self.friendName.text = @"张国文张国文";
    self.friendName.textAlignment = NSTextAlignmentLeft;
    self.friendName.font = [UIFont systemFontOfSize:k15Big];
    self.friendName.textColor = [UIColor blackColor];
    [grayBackView addSubview:_friendName];
    
    
    self.IDCheckTF = [[UITextView alloc] initWithFrame:CGRectMake(0, self.friendImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 140 * kAdjustParamater)];
    self.IDCheckTF.backgroundColor = [UIColor whiteColor];
    self.IDCheckTF.text = @"我是张国文";
    self.IDCheckTF.delegate = self;
    self.IDCheckTF.textColor = [UIColor blackColor];
    self.IDCheckTF.font = [UIFont systemFontOfSize:k15Big];
    [grayBackView addSubview:_IDCheckTF];
//    self.grayBackGround = [[UILabel alloc] initWithFrame:CGRectMake(0, self.friendImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 140 * kAdjustParamater)];
//    self.grayBackGround.backgroundColor = [UIColor whiteColor];
//    self.grayBackGround.userInteractionEnabled = YES;
//    [self.view addSubview:_grayBackGround];
//    
//    self.IDCheckTF = [[UITextField alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 110 * kAdjustParamater, kScreenWidth - 40 * kAdjustParamater, 20 * kAdjustParamater)];
//    self.IDCheckTF.backgroundColor = [UIColor redColor];
//    self.IDCheckTF.text = @"我阿斯顿发生地偶发金额就抢我肉发神经哦壹";
//    self.IDCheckTF.textAlignment = NSTextAlignmentLeft;
//    self.IDCheckTF.textColor = [UIColor blackColor];
//    self.IDCheckTF.delegate = self;
//    self.IDCheckTF.font = [UIFont systemFontOfSize:k14Big];
//    [self.view addSubview:_IDCheckTF];
//    
//    CGRect newFrame = self.IDCheckTF.frame;
//   newFrame.size.height = [[NetStatusHandle shareHandle] adjustHeight:self.IDCheckTF.text size:13 width:kScreenWidth - 40];
//    self.IDCheckTF.frame = newFrame;
}

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
    if ([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        return NO;
    }
    return YES;
}

- (void)textViewDidChange:(UITextView *)textView
{
    NSLog(@"textView = %@", textView.text);
}

//- (BOOL)textFieldShouldReturn:(UITextField *)textField
//{
//    [textField resignFirstResponder];
//    return YES;
//}
//
//- (void)textFieldDidEndEditing:(UITextField *)textField
//{
//    NSLog(@"textField = %@", textField.text);
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
